﻿//6. Write a program to convert binary numbers to hexadecimal numbers (directly).


using System;
using System.Collections.Generic;

class BinaryToHexadecimal
{
    static void Main()
    {
        string binaryNumber = Console.ReadLine();
        Console.WriteLine(GetBinaryHexadecimalString(binaryNumber));
        Console.WriteLine(Convert.ToInt32(binaryNumber, 2).ToString("X"));
    }

    static string GetBinaryHexadecimalString(string binaryNumber)
    {
        string hexaDNumber = String.Empty;

        while (binaryNumber.Length % 4 != 0)
        {
            binaryNumber = "0" + binaryNumber;
        }

        for (int i = 0; i < binaryNumber.Length; i = i + 4)
        {
            switch (binaryNumber.Substring(i, 4))
            {
                case "0000": hexaDNumber += "0";
                    break;
                case "0001": hexaDNumber += "1";
                    break;
                case "0010": hexaDNumber += "2";
                    break;
                case "0011": hexaDNumber += "3";
                    break;
                case "0100": hexaDNumber += "4";
                    break;
                case "0101": hexaDNumber += "5";
                    break;
                case "0110": hexaDNumber += "6";
                    break;
                case "0111": hexaDNumber += "7";
                    break;
                case "1000": hexaDNumber += "8";
                    break;
                case "1001": hexaDNumber += "9";
                    break;
                case "1010": hexaDNumber += "A";
                    break;
                case "1011": hexaDNumber += "B";
                    break;
                case "1100": hexaDNumber += "C";
                    break;
                case "1101": hexaDNumber += "D";
                    break;
                case "1110": hexaDNumber += "E";
                    break;
                default: hexaDNumber += "F";
                    break;
            }
        }
        return hexaDNumber;
    }
}
